<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

class TouristSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //

        //权限表
        app()['cache']->forget('spatie.permission.cache');
        $permission = [
            [
                'name'=>'index',
                'cn_name'=> '游客逛首页'
            ]  ,
            [
                'name'=>'comments.index',
                'cn_name'=>'游客看评论'
            ],
            [
                'name'=>'userinfo',
                'cn_name'=>'游客看别人信息'
            ],
            [
                'name'=>'categories.index',
                'cn_name'=>'游客看分类'
            ],
            [
                'name'=>'categories.index',
                'cn_name'=>'游客看分类'
            ],

        ];
        foreach ($permission as $p){
            Permission::create($p);
        }
        $role = Role::create(['name'=>'tourist','cn_name'=>'游客']);
//        $role->givePermissionTo();
        $role->givePermissionTo(Permission::all());
    }
}
